package com.aioz.security.controller;


import com.aioz.security.aop.annotation.LogInfoAnnotation;
import com.aioz.security.common.ResponseResult;
import com.aioz.security.entity.Position;
import com.aioz.security.entity.dto.PositionDto;
import com.aioz.security.service.impl.PositionServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Aioz
 * @since 2022-09-27
 */
@RestController
@RequestMapping("/position")
@Slf4j
public class PositionController {

    @Autowired
    private PositionServiceImpl positionService;

    //根据公司ID查询职位
    @PostMapping("/get/company/{companyId}/{currentPage}")
    public ResponseResult getPositionByCompanyId(@PathVariable Integer companyId,
                                                 @PathVariable Integer currentPage){
        return positionService.getPositionByCompanyId(companyId,currentPage);
    }

    // 根据ID查询具体职位
    @PostMapping("/like/{id}")
    public ResponseResult likePosition(@PathVariable Integer id){
        return positionService.likePosition(id);
    }

    // 高热度职位查询
    @GetMapping("/hot/top/{currentPage}")
    public ResponseResult hotTopPosition(@PathVariable Integer currentPage){
        return positionService.hotTopPosition(currentPage);
    }

    //根据类型查询岗位
    @PostMapping("/like/category/{category}")
    public ResponseResult likePositionByCategory(@PathVariable String category){
        return positionService.likePositionByCategory(category);
    }

    //关注职位
    @PostMapping("/interest/{positionId}")
    @LogInfoAnnotation
    public ResponseResult interestPosition(@PathVariable Integer positionId){
        return positionService.interestPosition(positionId);
    }

    //查询关注的职位
    @GetMapping("/get/interest")
    @LogInfoAnnotation
    public ResponseResult getInterestPosition(){
        return positionService.getInterestPosition();
    }

    //根据岗位名称模糊查询岗位信息
    @PostMapping("/like/dim/{name}/{id}")
    public ResponseResult likePositionByName(@PathVariable String name,
                                             @PathVariable Integer id){
        return positionService.likePositionByName(name,id);
    }

    //添加职位
    @PostMapping("/add")
    @LogInfoAnnotation
    public ResponseResult addPosition(@RequestBody Position position){
        log.info("{}",position);
        return positionService.addPosition(position);
    }

    //岗位停止招聘
    @PostMapping("/stop/{positionId}")
    @LogInfoAnnotation
    public ResponseResult stopRecruit(@PathVariable Integer positionId){
        log.info("ID为{} 的岗位停止招聘",positionId);
        return positionService.stopRecruit(positionId);
    }

    //更新岗位信息
    @PostMapping("/update/info")
    @LogInfoAnnotation
    public ResponseResult updatePositionInfo(@RequestBody PositionDto position){
        log.info("ID为{} 的岗位更新信息",position.getId());
        return positionService.updatePositionInfo(position);
    }

    //更多热门职位
    @PostMapping("/more/hot/{currentPage}")
    public ResponseResult moreHotPosition(@PathVariable Integer currentPage){
        return null;
    }

}
